package org.maylove.wuziqi.dao;

import jakarta.transaction.Transactional;
import org.maylove.wuziqi.pojo.discuss.discuss.Discuss;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DiscussDao extends JpaRepository<Discuss, Long> {

    Discuss findByDiscussId(Long discussId);

    @Transactional
    @Modifying
    void deleteByDiscussId(Long discussId);

    @Query(nativeQuery = true, value = "SELECT * FROM discuss ORDER BY discuss_id LIMIT ?,?")
    List<Discuss> getDiscuss(Integer start, Integer pageSize);
}
